﻿using System;

namespace Listing1_86
{
    public class Program
    {
        static void Main()
        {
            Pub p = new Pub();
            p.OnChange += (sender, e)
            => Console.WriteLine("Subscriber 1 called");
            p.OnChange += (sender, e)
            => { throw new Exception(); };
            p.OnChange += (sender, e)
            => Console.WriteLine("Subscriber 3 called");
            p.Raise();
        }
    }

    public class MyArgs : EventArgs
    {
        public MyArgs(int value)
        {
            Value = value;
        }
        public int Value { get; set; }
    }

    public class Pub
    {
        public event EventHandler OnChange = delegate { };

        public void Raise()
        {
            OnChange(this, EventArgs.Empty);
        }
    }
}
